package leetcode.jianzhioffer;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2021-10-27 15:38
 **/
public class JianZhiOffer53II {

    public int missingNumber(int[] nums) {
        int low = 0;
        int high = nums.length - 1;

        while (low <= high) {
            int avg = (low + high) >> 1;
            if (avg == nums[avg]) {
                low = avg + 1;
            } else {
                high = avg - 1;
            }
        }
        return low;
    }

}
